package com.lb.trac.pojo.condition.order;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;

import com.lb.trac.pojo.comparator.OrderBy;

public class FindTicketsOrderByStatoAndData implements OrderCondition {

	private int typeOrderData;
	private int typeOrderStato;

	public FindTicketsOrderByStatoAndData(int typeOrderData, int typeOrderStato) {
		this.typeOrderData=typeOrderData;
		this.typeOrderStato=typeOrderStato;
	}

	@Override
	public Object create(Object... objects) {
		Order data = typeOrderData==OrderBy.ASC?Order.asc("dataInserimento"):Order.desc("dataInserimento");
		Order stato = typeOrderStato==OrderBy.ASC?Order.asc("stati.idStato"):Order.desc("stati.idStato");
		return ((Criteria)objects[0]).addOrder(stato).addOrder(data);
	}

	@Override
	public void setType(int type) {
		// TODO Auto-generated method stub
		
	}

}
